# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>

pkgbase=gst-plugins-base
pkgname=(gst-plugins-base-libs gst-plugins-base)
pkgver=1.18.5
pkgrel=1
pkgdesc="Multimedia graph framework - base plugins"
url="https://gstreamer.freedesktop.org/"
arch=(x86_64)
license=(LGPL)
depends=(gstreamer orc libxv iso-codes libgudev mesa)
makedepends=(alsa-lib cdparanoia libvisual libvorbis libtheora pango opus
             graphene libpng libjpeg gobject-introspection git meson
             gtk3 qt5-{base,tools,x11extras} clutter sdl2 glu)
checkdepends=(xorg-server-xvfb)
options=(!emptydirs)
_commit=57fb883b3f8c6d7a397afc0dfc4a7c2e5af05579  # tags/1.18.5^0
source=("git+https://gitlab.freedesktop.org/gstreamer/gst-plugins-base.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd $pkgbase
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd $pkgbase
}

build() {
  arch-meson $pkgbase build \
    -D doc=disabled \
    -D tremor=disabled \
    -D gobject-cast-checks=disabled \
    -D package-name="GStreamer Base Plugins (Arch Linux)" \
    -D package-origin="https://www.archlinux.org/"
  meson compile -C build
}

check() (
  mkdir -p -m 700 "${XDG_RUNTIME_DIR:=$PWD/runtime-dir}"
  export XDG_RUNTIME_DIR

  xvfb-run -s '-nolisten local' \
    meson test -C build --print-errorlogs
)

package_gst-plugins-base-libs() {
  pkgdesc="${pkgdesc% plugins}"

  meson install -C build --destdir "$pkgdir"

  mkdir -p ext/lib/gstreamer-1.0
  for _x in alsa cdparanoia libvisual ogg opengl opus pango theora vorbis; do
    _x="lib/gstreamer-1.0/libgst${_x}.so"
    mv "$pkgdir/usr/$_x" "ext/$_x"
  done
}

package_gst-plugins-base() {
  depends=("gst-plugins-base-libs=$pkgver"
           alsa-lib cdparanoia libvisual libvorbis libtheora pango opus graphene libpng libjpeg)

  mv ext "$pkgdir/usr"
}
